﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http;
using Ross.EntityFramework;
using Ross.Service;
using Ross.Service.Dto;
using System.Web.Http.Results;

namespace Ross.Traning.Controllers
{
    [SimpleAuthenticationFilter]
    public class SignsController : BaseApiController
    {
        [HttpPost]
        public JsonResult<ResultDto<bool>> SignUp([FromBody] Service.Dto.Signs vm)
        {
            ResultDto<bool> result = new ResultDto<bool>();
            using (SignsService serv = new SignsService(dbContextStr))
            {
                result = serv.SignUp(vm);
            }
            return Json(result);
        }

        [HttpPost]
        public JsonResult<ResultDto<bool>> Delete(long id)
        {
            ResultDto<bool> result = new ResultDto<bool>();
            using (SignsService serv = new SignsService(dbContextStr))
            {
                result = serv.Delete(id);
            }
            return Json(result);
        }

        [HttpPost]
        public JsonResult<ResultDto<bool>> SignOver(long id)
        {
            ResultDto<bool> result = new ResultDto<bool>();
            using (SignsService serv = new SignsService(dbContextStr))
            {
                result = serv.SignOver(id);
            }
            return Json(result);
        }
        [HttpGet]
        public JsonResult<ResultDto<List<Signs>>> GetAllSigner(long teacherId = -1, long courseId = -1)
        {
            ResultDto<List<Signs>> result = new ResultDto<List<Signs>>();
            using (SignsService serv = new SignsService(dbContextStr))
            {
                result = serv.GetAllSigner(teacherId, courseId);
            }
            return Json(result);
        }
    }
}